# event listener
from direct.showbase import DirectObject
from Cube.command.QCommand.EventDefine import event_QCMD_CHATMESSAGE, event_QCMD_DATATRANSFER
# cmd event
from Cube.command.QCmdInputPipe.EventDefine import event_CMDPIPE_CMDEXECDONE

class QMapBodyHandler(DirectObject.DirectObject):
    def __init__(self):
        self.accept(event_CMDPIPE_CMDEXECDONE,self.CmdExecDoneHandler)
        self.accept(event_QCMD_CHATMESSAGE,self.ChatMessageHandle)
        self.accept(event_QCMD_DATATRANSFER,self.CmdHandle)

    def LogicUpdateOn(self):
        print "QMapBodyHandler.LogicUpdateOn"
        self.accept(event_CMDPIPE_CMDEXECDONE,self.CmdExecDoneHandler)

    def LogicUpdateOff(self):
        print "QMapBodyHandler.LogicUpdateOff"
        self.ignore(event_CMDPIPE_CMDEXECDONE)

    # override it
    def CmdExecDoneHandler(self, CmdDispatchPeriods):
        pass

    # override it
    def ChatMessageHandle(self, memberID, message):
        pass

    # override it
    def CmdHandle(self, memberID, param):
        print "CmdHandle", param
